"""
@author: lyf
@file: 随机点名系统.py
@time: 2022/11/6 20:56
"""
# 随机点名系统， 可以支持请假，抽点过了之后就不用再点了
import random
n1 = open('name','r',encoding='utf-8')
n2 = open('name_did','r+',encoding='utf-8')
n3 = open('name_leave','r',encoding='utf-8')
name = n1.read().splitlines()
name_did = n2.read().splitlines()
name_leave = n3.read().splitlines()
while name:
    n = random.choice(name)
    if len(name) == len(name_did) + len(name_leave):
        print("所有的同学都回答了")
        n2.seek(0)
        n2.truncate(0)
    if n in name and (n not in name_did )and( n not in name_leave):
        print(n)
        n2.write(n+'\n')
        break